# coding=utf-8
"""
CSDN_Python闯关特训营
第一周闯关作业_赵文川
本周共计3个作业：
1) 使用while和for…in两个循环分别输出四种九九乘法表效果（共计8个）。
2) 使用文件和目录操作，定义一个统计指定目录大小的函数（注意目录中还有子目录）。
3) 参考第9节的综合案例中的学生信息管理，来实现一个自动取款机的存取款模拟效果。要求有登陆和退出、查询余额、取钱，存钱等操作。
详情查看:http://csdn-edu-teacher.oss-cn-beijing.aliyuncs.com/230-170-1-1563872807.zip?OSSAccessKeyId=LTAInu0oRIELrjsF&Signature=viUMd38QKMzZGaKLDluUB2nVUuE%3D&Expires=1577357163
"""


# 1) 使用while和for…in两个循环分别输出四种九九乘法表效果（共计8个）。

# 定义MultiplicationMable_while_1()用while打印99乘法表其中1个样式的函数,问题:None多余打印
def MultiplicationMable_while_1():
    i = 1
    while i <= 9:
        j = 1
        while j <= i:
            print("%d*%d=%d" % (j, i, j * i), end="\t")
            if j == i:
                print()
            j += 1
        i += 1
    return "="*80


# 定义MultiplicationMable_while_2()用while打印99乘法表其中1个样式的函数
def MultiplicationMable_while_2():
    i = 9
    while i <= 9:
        j = 1
        while j <= i:
            print("{}*{}={}".format(j, i, j * i), end="\t")
            if j == i:
                print()
            j += 1
        i -= 1
    return "="*80


# 定义MultiplicationMable_while_3()用while打印99乘法表其中1个样式的函数
def MultiplicationMable_while_3():
    i = 1
    while i <= 9:
        k = 1
        while k <= 9 - i:
            print(end="        ")
            k += 1
        j = i
        while j >= 1:
            print("{}*{}={}".format(j, i, j * i), end="\t")
            j -= 1
        i += 1
        print()
    return "="*80


# 定义MultiplicationMable_while_4()用while打印99乘法表其中1个样式的函数
def MultiplicationMable_while_4():
    i = 9
    while i >= 1:
        k = 1
        print()
        while k <= 9 - i:
            print(end="        ")
            k += 1
        j = i
        while j >= 1:
            print("{}*{}={}".format(j, i, j * i), end="\t")
            j -= 1
        i -= 1
    return "\n"+"="*80


# 定义MultiplicationMable_ForIn_1()用for...in打印99乘法表其中1个样式的函数
def MultiplicationMable_ForIn_1():
    for i in range(1, 10):
        print()
        for j in range(1, i + 1):
            print("{}*{}={}".format(j, i, j * i), end="\t")

    return "="*80


# 定义MultiplicationMable_ForIn_2()用for...in打印99乘法表其中1个样式的函数
def MultiplicationMable_ForIn_2():
    for i in range(9, 0, -1):
        print()
        for j in range(1, i + 1):
            print("{}*{}={}".format(j, i, j * i), end="\t")
    return "\n"+"="*80


# 定义MultiplicationMable_ForIn_3()用for...in打印99乘法表其中1个样式的函数
def MultiplicationMable_ForIn_3():
    for i in range(1, 10):
        print()
        for k in range(1, 10 - i):
            print(end="        ")
        for j in range(i, 0, -1):
            print("{}*{}={}".format(j, i, j * i), end="\t")
    return "="*80


# 定义MultiplicationMable_ForIn_4()用for...in打印99乘法表其中1个样式的函数
def MultiplicationMable_ForIn_4():
    for i in range(9, 0, -1):
        print()
        for k in range(1, 10 - i):
            print(end="        ")
        for j in range(i, 0, -1):
            print("{}*{}={}".format(j, i, j * i), end="\t")
    return "\n"+"="*80


# print(MultiplicationMable_while_1(), MultiplicationMable_while_2(), MultiplicationMable_while_3())
print(MultiplicationMable_while_1())
print(MultiplicationMable_while_2())
print(MultiplicationMable_while_3())
print(MultiplicationMable_while_4())

